package com.four.homepage.todo;

import com.four.homepage.common.bean.ResponseData;
import com.four.homepage.common.controller.BaseController;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/todo")
public class TodoController  extends BaseController {
    @Autowired
    private TodoService todoService;

    //查
    @GetMapping("/list")
    public ResponseData<Object> listTodosByNumber() {
        return returnObject(todoService.selectTodosByNumber());
    }

    //删
    @DeleteMapping("/del/{id}")
    public ResponseData<Boolean> deleteTodosById(@PathVariable("id")Integer id){
        return returnBoolean(todoService.deleteTodosById(id));
    }

    //增
    @PostMapping("/add")
    public ResponseData<Boolean> addTodo(@RequestBody TodoEntity todoEntity){
        return returnBoolean(todoService.insertTodo(todoEntity));
    }
}
